package com.qmds.deviceserver.device.controller;

import com.qmds.common.core.annotation.NoLoginCheck;
import com.qmds.common.core.page.PageVO;
import com.qmds.common.core.vo.R;
import com.qmds.deviceserver.device.param.DeviceAddParam;
import com.qmds.deviceserver.device.param.DeviceEditParam;
import com.qmds.deviceserver.device.param.DevicePageParam;
import com.qmds.deviceserver.device.service.DeviceService;
import com.qmds.deviceserver.device.vo.DevicePageVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * --- 代码敲烂 月薪过万 ---
 *
 * @author ShiJiaWei
 * @date 2024/9/7
 * @desc:
 */
@RestController
@RequestMapping("/app/device")
public class DeviceController {

    @Resource
    private DeviceService deviceService;

    @GetMapping("/page")
    @NoLoginCheck
    public R<PageVO<DevicePageVO>> devicePage(DevicePageParam pageParam) {
        return deviceService.devicePage(pageParam);
    }

    @PostMapping("/add")
    public R<Integer> addDevice(@RequestBody DeviceAddParam addParam) {
        return deviceService.addDevice(addParam);
    }

    @PostMapping("/update")
    public R<Integer> updateDevice(@RequestBody DeviceEditParam editParam) {
        return deviceService.updateDevice(editParam);
    }

    @GetMapping("/status/echarts")
    public R<List<Map<String, Object>>> findStatusForCharts(Integer tid) {
        return deviceService.findStatusForCharts(tid);
    }
}
